﻿Public Structure Breuk

    Private _noemer As Integer

    Public Property Teller As Integer

    Public Property Noemer As Integer

        Get

            Return _noemer

        End Get

        Set(value As Integer)

            If value > 0 Then

                _noemer = value

            Else

                Throw New ArgumentException("Noemer mag niet nul zijn")

            End If

        End Set

    End Property

    Public ReadOnly Property Decimaal As Decimal

        Get

            Return Convert.ToDecimal(Teller / Noemer)

        End Get

    End Property

    Public Overrides Function ToString() As String

        Dim text As String

        If Teller < 0 Xor Noemer < 0 Then

            text &= "-"

        End If

        text &= Math.Abs(Teller) & "/" & Math.Abs(Noemer)

        Return text

    End Function

End Structure